/**
 * Created by YIJIEDAO2 on 2017/5/30.
 */
import React from 'react';

import { Button, Modal } from 'antd';

import Table from '../../../components/table';

import { myFetch } from '../../../utils/func';

const columns = [
  {
    title: '商品图',
    dataIndex: 'goodslogo',
    key: 'goodslogo'
  },
  {
    title: '商品名称',
    dataIndex: 'goodsname',
    key: 'goodsname'
  },
  {
    title: '单价',
    dataIndex: 'unitPrice',
    key: 'unitPrice'
  },
  {
    title: '类型',
    dataIndex: 'goodstype',
    key: 'goodstype'
  },
  {
    title: '简介',
    dataIndex: 'description',
    key: 'description'
  },
  {
    title: '备注',
    dataIndex: 'des',
    key: 'des'
  }

];

export default class Setting extends React.Component {

  constructor(props){

    super(props);
    this.state = {
      visible:false,
      key:'',
      data:[]
    }

  }

  componentDidMount(){

    let that = this;

    myFetch('/Goods/SearchGoodsList',{})
      .then(data=>{

        this.setState({
          data:data.data
        })

      })

  }

  openModal = () => {

    this.setState({
      visible:true,
      key:Math.random()
    })

  }

  handleOk = () => {

    this.handleCancel();

  }

  handleCancel = () => {

    this.setState({
      visible:false
    })

  }

  render(){
    return(
      <div>

        <Button type="primary" onClick={this.openModal}>新增商品</Button>

        <Modal
          key={this.state.key}
          title="Basic Modal"
          visible={this.state.visible}
          onOk={this.handleOk}
          onCancel={this.handleCancel}
        >
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>

        <Table columns={columns}/>

      </div>
    )
  }
}
